// pages/more_interests/more_interests.js
var url = require("../../utils/url.js");
var start = 1;
var data_type;
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  request_data: function() {
    var that = this;
    if (data_type.type == "game") {
      console.log("game=========")
      return
    }
    if (data_type.type == "movie") {
      url.interests_movie({
        id: data_type.id,
        start: start,
        count: 20,
        success: function(res) {
          console.log(res);
          if (start == 1) {
            that.setData({
              interests: res.data.interests,
              total: res.data.total
            })
          } else {
            var s = that.data.interests;
            var d = s.concat(res.data.interests)
            that.setData({
              interests: d
            })
          }          
        }
      });
    } else {
      url.interests_tv({
        id: data_type.id,
        count: 10,
        success: function(res) {
          console.log(res)
          if (start == 1) {
            that.setData({
              interests: res.data.interests,
              total: res.data.total
            })
          } else {
            var s = that.data.interests;
            var d = s.concat(res.data.interests)
            that.setData({
              interests: d
            })
          }        
        }
      });
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    wx.setNavigationBarTitle({
      title: "全部评论",
      success: function(res) {}
    })
    console.log(JSON.parse(options.id))
    var type = JSON.parse(options.id);
    data_type = type;
    var c = this.request_data();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    start = 1;
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    console.log("页面上拉触底======")
    start=start+20;
    this.request_data();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})